Add all needed targets to perform airgap installs on GKE - #317
Conversation
This deploys a Docker Registry v2 image. Registry is exposed in local-registry.default.svc.cluster.local and it is set up with a pvc. Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
This target parses all imagelist.txt files inside the buildfolder. For each image listed in the files, it spawns a kube job that uses `skopeo copy` to copy the image to the local repository. The target waits for all jobs to have succeeded. We are using dragonchaser/opensuse-skopeo:latest image, which contains podman (with vfs for unpriviliged containers), and skopeo. The kube jobs are configured to retry for 4 times, in case the jobs fail (they may, as all the jobs start at the same time, and my clog the cluster). Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
This is just a test target with a podman image that allows us to do podman pull. Signed-off-by: Christian Richter <crichter@suse.com>
Signed-off-by: Víctor Cuadrado Juan <vcuadradojuan@suse.de>
Also, don't call airgap-down and then airgap-up, when calling the old airgap-up target.
|
|
||
| .PHONY: airgap-up airgap-down | ||
| airgap-up airgap-down: | ||
| echo "Not implemented yet" && exit 1 |
There was a problem hiding this comment.
That's basically moving module-experimental-airgap-up here right?
I'm okay with doing that in a follow-up PR, but I expect by the time this whole thing is done we'll drop the experimental version?
Shouldn't the top-level makefile have a
airgap-up airgap-down:
$(MAKE) -C backend/$(BACKEND) $@| . ../../include/common.sh | ||
| . .envrc | ||
|
|
||
| export KUBECF_NAMESPACE=scf |
There was a problem hiding this comment.
It would be good to make this configurable (mostly because currently the namespace on GitHub CI is kubecf, because it's just using make kubecf-apply).
Of course, this will all change once RFD9 is in place.
| . ../../include/common.sh | ||
| . .envrc | ||
|
|
||
| export KUBECF_NAMESPACE=scf |
| export KUBECF_NAMESPACE=scf | ||
| export QUARKS_NAMESPACE=cf-operator | ||
| for ns in $KUBECF_NAMESPACE $QUARKS_NAMESPACE default; do | ||
| kubectl create namespace $ns || true |
There was a problem hiding this comment.
kubectl create namespace "${ns}" --dry-run=client -o yaml | kubectl apply -f -… now that I've typed it out that's just overly verbose and doesn't really help much, does it? I guess it catches errors other than the namespace already existing, but then we'll fail when we label it anyway. Nevermind, then.
| # GKE: Uses Calico, Use `--enable-network-policy` when | ||
| # creating a cluster (`gcloud`). | ||
| # Minikube needs special setup. | ||
| # KinD used by our Drone setup may have support. |
There was a problem hiding this comment.
FWIW, I don't think we have plans for a drone setup any longer.
| MIRROR='local-registry.default.svc.cluster.local' | ||
| echo ">>>>> Mirroring image: ${SOURCE_IMAGE}" | ||
| # add registry.suse.com/cap/ in front if it's not already there | ||
| if [[ $( echo $SOURCE_IMAGE | grep -o '/' | tr -d '\r\n' | wc -c) -lt 1 ]]; then |
There was a problem hiding this comment.
I'm trying to parse this line.
| Source | $SOURCE_IMAGE |
grep |
tr |
wc |
test |
|---|---|---|---|---|---|
| Docker library | debian:latest |
(empty) | (empty) | 0 | true |
| Docker Hub | cfcontainerization/image:tag |
/ |
/ |
1 | false |
| Registry | registry.suse.com/cap/image:tag |
// |
// |
2 | false |
So this will only mirror the "library" images (like debian:latest)? If that's the case, I think this line is equivalent to:
| if [[ $( echo $SOURCE_IMAGE | grep -o '/' | tr -d '\r\n' | wc -c) -lt 1 ]]; then | |
| if [[ -z "$(tr --complement --delete / <<< "${SOURCE_IMAGE}")" ]]; then |
If we actually wanted to do this for zero-or-one-slash things, that would be:
| if [[ $( echo $SOURCE_IMAGE | grep -o '/' | tr -d '\r\n' | wc -c) -lt 1 ]]; then | |
| if [[ "$(tr --complement --delete / <<< "${SOURCE_IMAGE}")" -lt 2 ]]; then |
|
|
||
| while IFS= read -r file | ||
| do | ||
| for SOURCE_IMAGE in $(cat "$imagelist_file"); do |
There was a problem hiding this comment.
Is this supposed to refer to file on line 42 instead?
| spec: | ||
| containers: | ||
| - name: copy-image | ||
| image: dragonchaser/opensuse-skopeo:latest |
There was a problem hiding this comment.
This image doesn't have the labels to indicate where the source comes from; we should probably add that. I assume that's modules/experimental/docker/Dockerfile.skopeo though?
|
|
||
| .PHONY: podman-imagelist | ||
| podman-imagelist: | ||
| ./podman-imagelist.sh |
There was a problem hiding this comment.
Hmm, it's unclear to me why we have two versions.
| # Include insecure registry | ||
| # shellcheck disable=SC2087 | ||
| ssh -T sles@${kube_node} << EOF | ||
| sudo sed 's/^\(CRIO_OPTIONS\s*=\s*\).*$/\1"--insecure-registry=${DOCKER_REGISTRY}"/' \ |
There was a problem hiding this comment.
We're wiping any existing options?

This PR enables testing airgapped clusters on GKE. It contains targets for setting up a
local-registry, pushing the images from imagelist.txt to the registry, and airgapping
the cluster via k8s networkPolicies. With this, one can test airgapped installs
of kubecf & quarks-operator.
Their implementation has been consciously made to be BACKEND-independent.
Prerequisites for full airgap installations:
GKE cluster).
Included in this PR:
Add BACKEND-side targets
airgap-upandairgap-downfor GKE and stubs forthe rest of backends. Those targets can be expanded in the future when each
backend satisfies the prerequisites.
Add networkPolicies for isolating the cluster by only allowing network
connections in the internal network, and external connections on DNS ports,
for anything on the
default,scf, andcf-operatornamespaces.These network policies are backend-independent, but they need a k8s Network
plugin present. At the moment, only GKE gets deployed with such, in that case,
Calico (by consuming Add Calico as networking plugin to GKE cap-terraform#98).
Add a
module-experimental-local-registrytarget. This target deploys aDocker v2 registry as a service in ns
default, only exposing it internallyto the cluster via the ClusterIP and the default
local-registry.default.svc.cluster.local DNS name. For Kubelet to correctly
pull images from the local registry, one needs to target its ClusterIP.
Add a
module-experimental-push-imagelisttarget. This target copies allimages listed in any imagelist.txt file in the buildfolder into the local
registry. This is done by spawning 1 k8s job per image to copy, each of which
performs a
skopeo copyand waiting for all jobs to finish successfully.We are using dragonchaser/opensuse-skopeo:latest image, which contains
podman and skopeo.
Add a
module-experimental-podman-imagelisttarget. This target spawns a podwith podman configured with vfs for unprivileged containers, and the
imagelist.txt files and a testing script inside the /tmp/ folder. Only useful
for manual testing and developing the airgap.